const express = require("express");
const cors = require("cors");
const bodyPaser = require("body-parser");
const article = require("./router/article");
const user = require("./router/user");

const app = express();
const port = 80;
app.listen(port);

// 跨域解决
app.use(
	cors({
		origin: [
			"http://127.0.0.1:8080",
			"http://localhost:8080",
			"http://qili.vaiwan.com",
		],
	})
);

// 引用bodyPaser
app.use(
	bodyPaser.urlencoded({
		extended: false,
	})
);

app.use(express.static("./public"));

// 路由模块
app.use("/article", article);
app.use("/user", user);

console.log("服务器启动", `监听端口${port}`);
